Next: , Previous: Secret Service API, Up: Top


4 Help for developers

The auth-source library only has one function for external use.

— Function: auth-source-user-or-password mode host port &optional username

Retrieve appropriate authentication tokens, determined by mode, for host host and port. If username is provided it will also be checked. If auth-source-debug is t, debugging messages will be printed. Set auth-source-debug to a function to use that function for logging. The parameters passed will be the same that the message function takes, that is, a string formatting spec and optional parameters.

If mode is a list of strings, the function will return a list of strings or nil objects (thus you can avoid parsing the netrc file or checking the Secret Service API more than once). If it's a string, the function will return a string or a nil object. Currently only the modes “login” and “password” are recognized but more may be added in the future.

host is a string containing the host name.

port contains the protocol name (e.g. “imap”) or a port number. It must be a string, corresponding to the port in the users' netrc files.

username contains the user name (e.g. “joe”) as a string.

          ;; IMAP example
          (setq auth (auth-source-user-or-password
                      '("login" "password")
                      "anyhostnamehere"
                      "imap"))
          (nth 0 auth) ; the login name
          (nth 1 auth) ; the password